package com.wangyb.common.base;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.io.Serializable;
import java.util.Collection;


/**
 * @Author: wangyb
 * @Date: 2021/7/6 5:12 下午
 */
public abstract class BaseServiceImpl<M extends BaseMapper<T>,T> extends ServiceImpl<M,T> {
	@Override
	public boolean saveOrUpdate(T entity) {
		if (beforeSave(entity)){
			return false;
		}
		boolean retValue = super.saveOrUpdate(entity);
		afterSave(entity);
		return retValue;
	}
	protected boolean beforeSave(T entity){
		return true;
	}
	protected void afterSave(T entity){

	}

	@Override
	public boolean removeByIds(Collection<? extends Serializable> idList) {
		return super.removeByIds(idList);
	}
	protected boolean beforeRemoveByIds(Collection<? extends Serializable> idList){
		return true;
	}
}
